#include "wifi.h"

void wifi_Init()
{
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);   //等待wifi模块稳定
//  wifi初始化完成 
}

bool wifi_Connect(const char *ssid, const char *password)
{
  uint8_t attempts = 0;
  
  WiFi.begin(ssid, password);
//  wifi连接中...
  
  while(WiFi.status() != WL_CONNECTED && attempts <= 20)
  {
      delay(1000);
      ++attempts;
  }

  if(WiFi.status() == WL_CONNECTED)
  {
    return true;  
  }
  else
  {
//   wifi连接失败
    return false;
  }
}
